{extend name="common/pop" /}
{block name="style"}
<style>
    body{
        background-color: #eeeeee;
        min-height:92%;
        overflow: auto;
        margin-bottom:5px;
    }
    .layui-row{
        margin:0 7.5px;
    }
    .j-breadcrumb{
        margin:10px!important;
    }
    .layui-col-md1{
        width:10%;
    }
</style>
{/block}
{block name="content"}
<div class="layui-card layui-card-breadcrumb j-breadcrumb">
    <div class="layui-card-header">{tag:currentmenu /}</div>
</div>

<style>
    .layui-card-body ul{
        width:100%;
    }
    .layui-card-body ul li{
        width:100%;
    }
    .layui-card-header ul li:first-child {
        float: left!important;
        margin-left: 0px!important;
    }
    .layui-card-header ul li {
        float: left!important;
        margin-left: 10px;
        text-align: center;
    }
    .layui-card-header ul li:last-child {
        float: left!important;
        margin-left: 10px;
        float: right!important;
    }
    .layui-card-header ul li font{
        font-size: 11px;
        color: #d2d2d2;
    }
    .layui-btn-group .layui-btn:first-child{
        margin-left: 0px;
    }
    .layui-btn-group .layui-btn{
        margin-left: 8px!important;
    }
    p{ text-indent:2em;}
</style>
<div class="layui-row layui-col-space5">
    {volist name="plugins" id="v"}
    <div class="layui-col-md3 ">
        <div class="layui-card">
            <div class="layui-card-header">
                <ul>
                    <li>
                        <img src="{$v.icon}" alt="" width="30px">
                    </li>
                    <li>
                        {if $v.is_admin == 1}
                            <a href="/plugins/{$v.flag}/admin/index" target="_blank">{$v.name}</a>
                        {else /}
                            <a href="/plugins/{$v.flag}/index" target="_blank">{$v.name}</a>
                        {/if}
                        &nbsp;<font>v1.0.1</font>
                    </li>
                    <li><a href="javascript:;">{$v.author|default="Janmas"}</a></li>
                </ul>

            </div>
            <div class="layui-card-body">
                <ul>
                    <li style="height:120px;">  <p>{$v.description|default="作者有点懒啥都没写"}</p></li>
                    <hr>
                    <li>
                        <div class="layui-btn-group">
                            {if $v.is_install == 0}
                            <button class="layui-btn layui-btn-xs" onclick="install(this,'{$v.flag}')">安装</button>
                            {else/}
                            <button class="layui-btn layui-btn-xs layui-btn-danger" onclick="uninstall(this,'{$v.flag}')">卸载</button>
                            {/if}
                            {if $v.is_config == 1}
                            <button class="layui-btn layui-btn-xs layui-btn-warm" onclick="config(this,'{$v.flag}')">配置</button>
                            {/if}
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
    {/volist}

    <div  class="layui-col-md3 ">
        <div class="layui-card">
            <div class="layui-card-header">
                <ul>
                    <li>
                        <img src="/plugins/demo/icon.png" alt="" width="30px">
                    </li>
                    <li>
                        <a href="javascript:;">插件名</a>
                    </li>
                    <li>作者:<a href="">Janmas</a></li>
                </ul>
            </div>
            <div class="layui-card-body">
                <ul>
                    <li style="height:120px;">插件描述</li>
                    <hr>
                    <li>
                        <div class="layui-btn-group">
                            <button class="layui-btn layui-btn-xs layui-btn-normal">安装</button>
                            <button class="layui-btn layui-btn-xs layui-btn-danger">卸载</button>
                            <button class="layui-btn layui-btn-xs layui-btn-warm">配置</button>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
    var layer = null
    layui.use('layer',function(){
        layer = layui.layer;
    })
    function install(e,flag){
        layer.load();
        $.get('install', {flag:flag},function(r){
            layer.closeAll();
            layer.msg(r.msg);
            if(r.code == 1){
                setTimeout(function(){
                    window.location.reload();
                },1500)
            }else{
            }
        },'json')
    }

    function uninstall(e,flag){
        layer.load();
        $.get('uninstall', {flag:flag},function(r){
            layer.closeAll();
            layer.msg(r.msg);
            if(r.code == 1){
                setTimeout(function(){
                    window.location.reload();
                },1500)
            }else{
            }
        },'json')
    }
    function config(e,flag){
        layer.open({
            type:2,
            content:"{:url('Plugin/config')}?flag=" + flag,
            shadeClose:true,
            area:['80%','80%']
        })
    }

    function info(e,flag){
        layui.use('layer',function(){
            var layer = layui.layer;
            layer.tips($('textarea[name='+flag+']').val(), $(this).parents('.layui-col-md1'), {
                tips: [1, '#000000'],
                time: 4000
            });
        })

    }
</script>
{/block}

